// pmView.h : interface of the CPmView class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once

#include <atlcrack.h>

#include <string>

#include "VirtualListView.h"
#include "ListModel.h"

#define FORWARD_MSG_RANGE(msgFirst, msgLast) if(uMsg >= msgFirst && uMsg <= msgLast) \
    { lResult = ::SendMessage( GetParent(), uMsg, wParam, lParam ); return bHandled = FALSE; }

#define FORWARD_MSG(msg) if(uMsg == msg) \
    { lResult = ::SendMessage( GetParent(), uMsg, wParam, lParam ); return bHandled = FALSE; }


class ListView : public VirtualListView< ListView >
{
public:
    ListView() {}
                                              
	BEGIN_MSG_MAP_EX(ListView)
        MESSAGE_HANDLER(WM_PAINT, OnPaint)
		FORWARD_MSG( WM_KEYDOWN )
        CHAIN_MSG_MAP( VirtualListView< ListView > )
	END_MSG_MAP()

    void SetModel(ListModel * mdl);
    void UpdateModel();

    std::wstring GetItemText(int item, int subitem);

    LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);

    void UpdateItemWidth();

protected:

    ListModel* model;
};
